import { createI18n } from 'vue-i18n'
import zh from "./zh.json"
import en from "./en.json"
import hk from "./hk.json"

const i18n = createI18n({
    locale: 'zh',
    messages: {
        zh,
        en,
        hk
    }
})
export let $t = (key, place) => {
    let res = i18n.global.t(key, place)
    if (place) {
        for (let key in place) {
            res = res.replace(new RegExp(`\\{\\s*${key}\\s*\\}`, 'g'), place[key])
        }
    }
    return res
}
export const t = $t;
export default i18n